package com.tvunetworks.center.device.controller;

import com.netflix.discovery.EurekaClient;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.PreDestroy;

/**
 * @program: tvucc-aggregator
 * @description: BaseController
 * @author lebronchen
 * @create: 2020-05-14 16:23
 **/
@RestController
@RequestMapping("/base")
@Slf4j
public class BaseController {

    @Value("${buildversion}")
    private String buildversion;
    @Value("${commonBuildversion}")
    private String commonBuildversion;

    /**
     *
     * @return version
     */
    @GetMapping("/version")
    public String version (){
        return buildversion + "|" + commonBuildversion;
    }



    @Autowired
    private EurekaClient eurekaClient;
    /**
     * 销毁Eureka注册
     */
    @PreDestroy
    public void stop() {
        if (eurekaClient != null) {
            log.error("Shutting down server and notify to Eureka  by  tvucc-device.");
            eurekaClient.shutdown();
        }
    }
}
